{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=537
  Verdict: Accepted
}
uses SysUtils;
 
var
	i,n,tp,cc,mx:longint;
	a,b:array[0..1010] of longint;
	t:array[0..1010] of string;
	s:string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
fillchar(a,sizeof(a),0);
cc:=0;
for i:=1 to n do begin
	readln(tp);
	if tp=0 then begin
		inc(cc);
		readln(s);
		t[cc]:=s;
		readln(s);
		a[cc]:=1;
		b[i]:=cc;
	end else begin
		readln(s);
		inc(a[b[tp]]);
		b[i]:=b[tp];
	end;
end;
mx:=1;
for i:=2 to cc do
	if a[i]>a[mx] then mx:=i;
write(t[mx]);
end.